<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<html lang="en-us" xml:lang="en-us">
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="DC.Type" content="topic">
  <meta name="DC.Title" content="Step1: Enabling the Archive Mode (Applicable Only to CMDB)">
  <meta name="product" content="">
  <meta name="DC.Relation" scheme="URI" content="opengauss-0111.html">
  <meta name="prodname" content="">
  <meta name="version" content="">
  <meta name="brand" content="30-OceanProtect Appliance 1.5.0-1.6.0 Help Center">
  <meta name="DC.Publisher" content="20241029">
  <meta name="prodname" content="csbs">
  <meta name="documenttype" content="usermanual">
  <meta name="DC.Format" content="XHTML">
  <meta name="DC.Identifier" content="postgresql-0010">
  <meta name="DC.Language" content="en-us">
  <link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
  <title>Step1: Enabling the Archive Mode (Applicable Only to CMDB)</title>
 </head>
 <body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px">
  <a name="postgresql-0010"></a><a name="postgresql-0010"></a>
  <h1 class="topictitle1">Step1: Enabling the Archive Mode (Applicable Only to CMDB)</h1>
  <div>
   <p>Before backing up a CMDB database, you must enable the archive mode. Otherwise, the backup fails.</p>
   <div class="section">
    <h4 class="sectiontitle">Procedure</h4>
    <ol>
     <li><span>Use PuTTY to log in to the CMDB database host.</span></li>
     <li><span>Run the following command to switch to the database installation user. The following uses user <strong>omm</strong> as an example.</span><p></p><pre class="screen">su - omm</pre> <p></p></li>
     <li><span>Run the following command to create a path for storing archive logs (WAL logs). The <span class="filepath"><b>/database/panweidb/archive/</b></span> path is used as an example in subsequent operations.</span><p></p><pre class="screen">mkdir -p /database/panweidb/archive/</pre> <p></p></li>
     <li><span>Log in as the database administrator.</span><p></p>
      <ol type="a">
       <li>On the host, open the <strong>postgresql.conf</strong> file. The <span class="filepath"><b>/database/panweidb/data/postgresql.conf</b></span> path is used as an example.<pre class="screen">vi /database/panweidb/data/postgresql.conf</pre> <p>In the following command output, the queried port number is displayed in the row where <strong>port</strong> is located. Port number <strong>17700</strong> is used as an example.</p> <p><span><img src="en-us_image_0000002029367544.png"></span></p></li>
       <li>Run the following command to log in as database administrator <strong>postgres</strong>:</li>
      </ol> <pre class="screen">gsql -d postgres -p <em>17700</em></pre> <p></p></li>
     <li><span>Run the <strong>show config_file</strong><strong>;</strong> command to query the path to the <strong>postgresql.conf</strong> file.</span><p></p>
      <div class="p">
       The following is an example of the command output:
       <pre class="screen">postgres=# show config_file;
              config_file
---------------------------------------
/database/panweidb/data/postgresql.conf
(1 row)</pre>
      </div> <p></p></li>
     <li><span>On the database host, open the <strong>postgresql.conf</strong> file. The <span class="filepath"><b>/database/panweidb/data/postgresql.conf</b></span> path is used as an example.</span><p></p><pre class="screen">vi /database/panweidb/data/postgresql.conf</pre> <p></p></li>
     <li><span>Modify the <strong>wal_level</strong>, <strong>archive_mode</strong>, and <strong>archive_command</strong> parameters in the <strong>postgresql.conf</strong> file as follows:</span><p></p><pre class="screen">wal_level = hot_standby                 # minimal, archive, hot_standby or logical
archive_mode = on               # enables archiving; off, on, or always
archive_command = 'cp %p /database/panweidb/archive/%f'          # command to use to archive a logfile segment</pre>
      <div class="note">
       <img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span>
       <div class="notebody">
        <ul>
         <li>Set <strong>wal_level</strong> to <strong>archive</strong>, <strong>hot_standby</strong>, or <strong>logical</strong>.</li>
         <li>Set <strong>archive_mode</strong> to <strong>on</strong>.</li>
         <li>Set <strong>archive_command</strong> to <strong>'cp %p /mnt/server/archivedir/%f'</strong>.</li>
         <li>When modifying the <strong>postgresql.conf</strong> file, change the values of existing fields in the file. Do not add the same fields to the file. Otherwise, the restoration job will be affected.</li>
         <li>When enabling the archive mode, you need to set the same archive log path on all active and standby nodes of the database.</li>
        </ul>
       </div>
      </div> <p></p></li>
     <li><span>Run the following command to restart the database:</span><p></p><pre class="screen">pw_ctl restart -D /database/panweidb/data</pre>
      <div class="notice">
       <span class="noticetitle"><img src="public_sys-resources/notice_3.0-en-us.png"> </span>
       <div class="noticebody">
        <p>Database services will be interrupted during the restart. Exercise caution when performing this operation.</p>
       </div>
      </div> <p></p></li>
    </ol>
   </div>
  </div>
  <div>
   <div class="familylinks">
    <div class="parentlink">
     <strong>Parent topic:</strong> <a href="opengauss-0111.html">Backing Up openGauss/CMDB</a>
    </div>
   </div>
  </div>
 </body>
</html>